﻿<UserControl x:Class="Kaskelot.SP.UI.Analys.Controls.CheckboxQueryBuilder"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
	xmlns:viewModels="clr-namespace:Kaskelot.SP.UI.Analys.ViewModel;assembly=Kaskelot.SP.UI.Analys.Data"
	xmlns:my="clr-namespace:Kaskelot.SP.UI.Analys.Controls"
	mc:Ignorable="d"
	d:DataContext="{d:DesignInstance Type=viewModels:Query, IsDesignTimeCreatable=False}"
	d:DesignHeight="600" d:DesignWidth="920">

	<UserControl.Resources>
		<my:ComboStyleSelector x:Key="ComboSelector"/>
	</UserControl.Resources>

	<Border Background="#e6e6e6" BorderBrush="#d6d6d6" BorderThickness="1">
		<Grid x:Name="LayoutRoot" Background="Transparent" >
			<Grid.RowDefinitions>
				<RowDefinition Height="45"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="45"/>
			</Grid.RowDefinitions>

			<StackPanel Orientation="Horizontal">
				<TextBlock x:Name="CreateNewSelection" VerticalAlignment="Center" Style="{StaticResource QueryBuilderHeading}" Cursor="Hand" MouseLeftButtonUp="ShowQuerySelection_MouseLeftButtonUp" Text="Skapa nytt urval" />
				<Border BorderBrush="Gray" BorderThickness="0, 0, 1, 0" Height="20" Margin="5, 0, 5, 0"/>
				<TextBlock x:Name="SelectSavedSelection" VerticalAlignment="Center" Style="{StaticResource QueryBuilderHeadingDisabled}" Cursor="Hand" MouseLeftButtonUp="ShowQuerySelection_MouseLeftButtonUp" Text="Välj från sparat urval" />
				<telerik:RadComboBox Name="SavedQueryChoice" Width="350" Margin="5, 0, 0, 0" Height="20" ItemsSource="{Binding SavedQueries}" 
					DisplayMemberPath="Name" telerik:StyleManager.Theme="Summer" HorizontalAlignment="Left" VerticalAlignment="Center" ItemContainerStyleSelector="{StaticResource ComboSelector}" Visibility="Collapsed" SelectionChanged="SavedQueryChoice_SelectionChanged" />
			</StackPanel>

			<StackPanel Orientation="Vertical" Grid.Row="1">
				<StackPanel Orientation="Horizontal">
					<StackPanel Orientation="Vertical">
						<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Style="{StaticResource CheckboxListHeading}" Text="Välj primär entitet" />
						<telerik:RadComboBox Name="PrimaryEntityChoice" ItemsSource="{Binding Query.PrimaryEntities}" SelectedItem="{Binding PrimaryEntity, Mode=TwoWay}" DisplayMemberPath="Name" Width="150" telerik:StyleManager.Theme="Summer" ItemContainerStyleSelector="{StaticResource ComboSelector}" Margin="5,0,5,5" />
						<my:CheckboxFieldPicker DataContext="{Binding PrimaryEntity}" HideEntityTitle="True" />
					</StackPanel>
					<StackPanel Orientation="Vertical">
						<TextBlock VerticalAlignment="Center" Style="{StaticResource CheckboxListHeading}" Text="Relaterade entiteter" />
						<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled" Width="900" MinHeight="200" BorderBrush="Transparent">
							<ScrollViewer.Content>
								<ItemsControl ItemsSource="{Binding RelatedEntities}">
									<ItemsControl.ItemsPanel>
										<ItemsPanelTemplate>
											<StackPanel Orientation="Horizontal"></StackPanel>
										</ItemsPanelTemplate>
									</ItemsControl.ItemsPanel>
									<ItemsControl.ItemTemplate>
										<DataTemplate>
											<my:CheckboxFieldPicker />
										</DataTemplate>
									</ItemsControl.ItemTemplate>
								</ItemsControl>
							</ScrollViewer.Content>
						</ScrollViewer>
					</StackPanel>
				</StackPanel>
			</StackPanel>
			<my:FilterBox Grid.Row="1" HorizontalAlignment="Right" x:Name="FilterContainer" VerticalAlignment="Top" Canvas.ZIndex="10" DataContext="{Binding SelectedEntities}" />
			<Border Grid.Row="2" Width="920">
				<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
					<HyperlinkButton Name="ResetButton" Click="ResetButton_Click" HorizontalAlignment="Right" Margin="0,0,10,0" Padding="0,0,0,0" Content="Rensa" />
					<Button Name="GoButton" Click="GoButton_Click" Height="26" HorizontalAlignment="Right" Margin="0,0,10,0" Padding="0,0,0,0" Width="90" Content="Visa" />
					<Button Name="SaveButton" Click="SaveButton_Click"  Height="26" HorizontalAlignment="Right" Margin="0,0,10,0" Padding="0,0,0,0" Visibility="Collapsed" Width="90" Content="Spara" />
					<Button Name="SaveAsButton" Click="SaveAsButton_Click" Height="26" HorizontalAlignment="Right" Margin="0,0,10,0" Padding="0,0,0,0" Width="90" Content="Spara som" />
					<Button Name="DeleteButton" Click="DeleteButton_Click" Height="26" HorizontalAlignment="Right" Margin="0,0,10,0" Padding="0,0,0,0" Visibility="Collapsed" Width="90" Content="Ta bort" />
				</StackPanel>
			</Border>
		</Grid>
	</Border>
</UserControl>
